sinclude ../script/env.mk
sinclude ../script/localenv.mk

ARCH		:= arch/X86

X_ASFLAGS	:= $(ENV_AFLAGS) -I $(ARCH)/include/
X_CFLAGS    := $(ENV_CFLAGS) -fno-strict-aliasing -O0

ifeq ("$(origin G)", "command line")
ifeq ($(G),on)
X_CFLAGS	+= -O0 -g -ggdb
X_ASFLAGS	+= -DGDB
endif
endif

X_INCDIRS	:= include/ $(ARCH)/include/ include/lib

ifeq ($(KERNEL_MODULE_NET),y)
X_INCDIRS	+= system/net/lwip/include/ system/net/lwip/include/ipv4/
X_CFLAGS	+= -DCONFIG_NET
# 如果要在用户态实现网络协议栈，就需要用netremote
# X_CFLAGS	+= -DCONFIG_NETREMOTE
endif

ifeq ($(KERNEL_LIVECD_MODE),y)
X_CFLAGS	+= -DCONFIG_LIVECD
endif

X_LDFLAGS	:=  $(ENV_LDFLAGS)

AS			:=	$(ENV_AS)
LD			:=  $(ENV_LD)

export AS LD
export ARCH

SRC			:= $(ARCH)/ system/ driver/ lib/

NAME		:= CATOS.elf

ifeq ($(BOOT_MODE),$(BOOT_LEGACY_MODE))
	KERNEL_LD_FILE = kernel-myboot.ld
	MODULE += $(ARCH)/boot/myboot
else
	KERNEL_LD_FILE = kernel.ld
	MODULE += $(ARCH)/boot
endif

define CUSTOM_TARGET_CMD
echo [KERNEL] $@; \
$(LD) $(X_LDFLAGS) -n -T $(ARCH)/$(KERNEL_LD_FILE) -o $@ $(X_OBJS)
endef